import { request } from '@/api/request'

// 新增工单
export function addOrder(data) {
  return request({
    url: '/system/order',
    method: 'post',
    data: data
  })
}

// 查询工单列表
export function queryOrderList(data) {
  return request({
    url: '/system/order/list',
    method: 'post',
    data: data
  })
}

// 删除工单
export function deleteOrder(data) {
  return request({
    url: '/system/order/batchDelete',
    method: 'post',
    data: data
  })
}

// 编辑工单
export function updateOrder(data) {
  return request({
    url: '/system/order',
    method: 'put',
    data: data
  })
}

// 获取留言列表
export function detailList(data) {
  return request({
    url: '/system/order/detail/list',
    method: 'post',
    data: data
  })
}

// 发送工单留言
export function sendChat(data) {
  return request({
    url: '/system/order/detail',
    method: 'post',
    data: data
  })
}

// 已读工单
export function read(data) {
  return request({
    url: '/system/order/detail/read',
    method: 'put',
    data: data
  })
}


//查询购物车列表
export function list(data) {
  return request({
    url: '/system/car/list',
    method: 'post',
    data: data
  })
}

// 移除购物车
export function deleteCart(data) {
  return request({
    url: '/system/car/batchDelete',
    method: 'post',
    data: data
  })
}

//查询用户 我的云服务器列表
export function relationList(data) {
  return request({
    url: '/system/relation/list',
    method: 'post',
    data: data
  })
}

//统计云服务器状态
export function statisticsStatus(data) {
  return request({
    url: '/system/relation/statisticsStatus',
    method: 'post',
    data: data
  })
}

//查询财务流水列表
export function walletLogList(data) {
  return request({
    url: '/system/manager/walletLogList',
    method: 'post',
    data: data
  })
}

//查询财务统计
export function walletCountList(data = {}) {
  return request({
    url: '/system/manager/statisticsWalletLogList',
    method: 'post',
    data: data
  })
}

//查询子订单列表
export function itemList(data) {
  return request({
    url: '/system/order/item/list',
    method: 'post',
    data: data
  })
}

//查询站内消息列表
export function messageList(data) {
  return request({
    url: '/system/message/list',
    method: 'post',
    data: data
  })
}

// 消息已读 (传isAll: 2全部已读)
export function messageRead(data) {
  return request({
    url: '/system/message/edit',
    method: 'post',
    data: data
  })
}

// 查询未读消息数
export function getMessagedNum() {
  return request({
    url: '/system/message/getUnreadNum',
    method: 'get',
  })
}

// 消息详情
export function messageDetail(data) {
  return request({
    url: '/system/message/getInfo',
    method: 'post',
    data: data
  })
}

//购买服务器(付款)
export function buyServer(data) {
  return request({
    url: '/cloud/buyServer',
    method: 'post',
    data: data
  })
}

//查询发票列表
export function invoiceManagementList(data) {
  return request({
    url: '/system/invoiceManagement/list',
    method: 'post',
    data: data
  })
}

//查询合同列表
export function contractList(data) {
  return request({
    url: '/system/contract/list',
    method: 'post',
    data: data
  })
}

// 申请合同
export function contractAdd(data) {
  return request({
    url: '/system/contract',
    method: 'post',
    data: data
  })
}

// 作废合同
export function contractCancel(id) {
  return request({
    url: '/system/contract/cancel/' + id,
    method: 'get'
  })
}

// 合同下载
export function contractDownload(data) {
  return request({
    url: '/system/contract/download',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

// 未开合同订单列表
export function contractOrderList(params) {
  return request({
    url: '/system/contract/orderList',
    method: 'get',
    params: params
  })
}

// 公司信息 COMPANY_INFORMATION 企业信息 CONTRACT_COMPANY_INFORMATION 合同模板中公司信息
export function contractCompany(type) {
  return request({
    url: `/system/information/settingType/${type}`,
    method: 'get'
  })
}

// 合同详情
export function contractInfo(id) {
  return request({
    url: `/system/contract/${id}`,
    method: 'get'
  })
}

//管理端新增发票
export function invoiceManagementInsert(data) {
  return request({
    url: '/system/invoiceManagement/insert',
    method: 'post',
    data: data
  })
}

// 申请发票
export function invoiceApply(data) {
  return request({
    url: '/system/invoiceManagement/applyForInvoicing',
    method: 'post',
    data: data
  })
}

// 发票设置
export function invoiceConfig(data) {
  return request({
    url: '/system/userInvoiceInformation',
    method: 'post',
    data: data
  })
}

// 发票查询
export function queryInvoiceConfig(params = {}) {
  return request({
    url: '/system/userInvoiceInformation/getByLoginUser',
    method: 'get',
    params
  })
}

// 查询发票详情
export function queryInvoiceDetail(id) {
  return request({
    url: '/system/userInvoiceInformation/getById/' + id,
    method: 'get'
  })
}

// 获取订单状态
export function getOrderState(sn = '') {
  return request({
    url: `/cloud/order/getBySn/${sn}`,
    method: 'get',
  })
}
